home *** CD-ROM | disk | FTP | other *** search
- Path: newshost.lanl.gov!tanmoy
- From: tanmoy@qcd.lanl.gov (Tanmoy Bhattacharya)
- Newsgroups: comp.lang.c
- Subject: Re: Quotes in C comments
- Date: 13 Mar 1996 16:25:51 GMT
- Organization: Los Alamos National Laboratory
- Message-ID: <TANMOY.96Mar13092551@qcd.lanl.gov>
- References: <Do6nn5.5rE@oscar.prima.ruhr.de>
- NNTP-Posting-Host: qcd.lanl.gov
- Mime-Version: 1.0
- Content-Type: text
- In-reply-to: patrick@oscar.prima.ruhr.de's message of Wed, 13 Mar 1996 01:47:29 GMT
-
- In article <Do6nn5.5rE@oscar.prima.ruhr.de>
- patrick@oscar.prima.ruhr.de (Patrick Mau) writes:
- <snip>
- PM: I had a really funny problem with quotes in C programs:
-
- Let us first decide what we are talking about: the language C has a
- very standardized meaning today. In the past the same name had been
- used for many of its predecessors, which were specified only by what
- the compilers did. Since you said C, I shall assume you meant the
- language we call C today.
-
- PM:
- PM: The question is:
- PM: How should a compiler handle the following comments
- PM:
- PM: First Example:
- PM:
- PM: /*
- PM: * printf( "/* funny printf */" );
- PM: * ^^--- Point A
- PM: */
- PM:
- PM: Second Example:
- PM:
- PM: /*
- PM: * You can't do xyz here
- PM: * ^--- Point B
- PM: */
- PM:
- PM: In the first example the compiler could stop at point A thinking the
- PM: comment ends at that point. This would be the case if the compiler
- PM: doesn't check quotes within comments. ( they are usually ignored. )
-
- Quotes in comments get no special treatment: the very first */ inside
- a comment ends the comment. (Note that /* has no special treatment
- either, so comments cannot nest.) So, your comment indeed ends at
- point A.
-
- PM:
- PM: In the second example ( _that_ happened to me with gcc 2.7.2 )
- PM: the compiler complains about an unterminated character constant
- PM: at EOF and says it could be at point B.
-
- If this is really true, throw away the compiler. The only character
- sequence of any significance within a comment is */, because that ends
- the comment.
-
- Could you post a small example showing this (and the exact error
- message that gcc produces)? I am 99% sure that what you are saying is
- not correct.
-
- Are you confusing #if 0 with a comment?
-
- PM:
- PM: How should a good compiler handle those kinds of comments.
- PM: Should it check for quotes within comments or not ?
-
- Quotes within comments are just ordinary characters and need no
- special treatment. A /* inside a quote or a comment does not start a
- comment.
-
- Cheers
- Tanmoy
- --
- tanmoy@qcd.lanl.gov(128.165.23.46) DECNET: BETA::"tanmoy@lanl.gov"(1.218=1242)
- Tanmoy Bhattacharya O:T-8(MS B285)LANL,NM87545 H:#9,3000,Trinity Drive,NM87544
- Others see <gopher://yaleinfo.yale.edu:7700/00/Internet-People/internet-mail>,
- <http://alpha.acast.nova.edu/cgi-bin/inmgq.pl>or<ftp://csd4.csd.uwm.edu/pub/
- internetwork-mail-guide>. -- <http://nqcd.lanl.gov/people/tanmoy/tanmoy.html>
- fax: 1 (505) 665 3003 voice: 1 (505) 665 4733 [ Home: 1 (505) 662 5596 ]
-